<template>
	<div :class="$style.picker">
		<ul>
			<li @click="setBuyAmount(1)" :style="liStyle">
				<p>全仓</p>
				<p>{{ buyEnableVol | floor100 }}</p>
			</li>
			<li @click="setBuyAmount(2)" :style="liStyle">
				<p>1/2仓</p>
				<p>{{ buyEnableVol / 2 | floor100 }}</p>
			</li>
			<li @click="setBuyAmount(3)" :style="liStyle">
				<p>1/3仓</p>
				<p>{{ buyEnableVol / 3 | floor100 }}</p>
			</li>
			<li @click="setBuyAmount(4)" :style="liStyle">
				<p>1/4仓</p>
				<p>{{ buyEnableVol / 4 | floor100 }}</p>
			</li>
		</ul>
	</div>
</template>

<script>
	import floor100 from '../../../filters/floor100'

	export default {
		props: ['gameid'],
		filters: {
			floor100
		},

		computed: {
			buyEnableVol () {
				return parseInt(this.$store.state.buyEnableVol) || 0
			},
			liStyle () {
				return {
					border: !!this.gameid ? '1px solid #FFBC80' : '1px solid #FFC2C2',
					backgroundColor: !!this.gameid ? '#D13200' : '#A23030'
				}
			}
		},

		methods: {
			setBuyAmount (rate) {
				this.$store.dispatch('setBuyAmount', floor100(this.buyEnableVol * 1 / rate))
			}
		}
	}
</script>

<style lang="less" module>

	.picker {
		position: static!important;
	}

	.picker p {
		margin: 0;
		font-size: 12px;
		line-height: 14px;
	}

	.picker ul {
		overflow: hidden;
		margin-top: 12px;
		padding: 0;
		display: -webkit-box;
	}

	.picker li {
		-webkit-box-flex: 1;
		text-align: center;
		list-style: none;
		border-radius: 999px;
		width: 25%;
		padding: 3px;
		color: #FFF;
		// background: rgba(0, 0, 0, 0.2);

		-webkit-tap-highlight-color: #FFF;
		p {
			-webkit-tap-highlight-color: #6ba9af;
		}

		&:active {
			background-color: #FFF;
			color: #6ba9af;
		}

		&:not(:first-child) {
			margin-left: 13px;
		}
	}
</style>
